﻿Imports System.Data.OleDb
Public Class Rating
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles GridView1.SelectedIndexChanged

    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
        Dim conn As OleDbConnection = New OleDbConnection(ConfigurationManager.ConnectionStrings("maniaConnectionstring").ConnectionString)
        conn.Open()
        Dim delprevRatings = "delete from rate where rater=@f1 and Resultid=@f2"
        Dim cmd1 As OleDbCommand = New OleDbCommand(delprevRatings, conn)

        cmd1.Parameters.AddWithValue("@f1", User.Identity.Name)
        cmd1.Parameters.AddWithValue("@f2", Request.Params("ID"))
        cmd1.ExecuteNonQuery()
        Dim sql = "Insert into rate (rating,rater,resultid) values (@f1,@f2,@f3)"
        Dim cmd As OleDbCommand = New OleDbCommand(sql, conn)

        cmd.Parameters.AddWithValue("@f1", Rating1.CurrentRating)
        cmd.Parameters.AddWithValue("@f2", User.Identity.Name)
        cmd.Parameters.AddWithValue("@f3", Request.Params("ID"))
        cmd.ExecuteNonQuery()
        conn.Close()
        cmd.Dispose()
        conn.Dispose()



    End Sub
End Class